#!/usr/bin/env python

"""
SpeedCurve.py: A model to convert splits into a flat series of velocities.
"""

class FlatSpeedCurve:
	# Instance variables
	ts = []
	ds = []
	t = []

	def getSpeed( self ):
		tsc = []
		tssum = 0.0
		for tsi in self.ts:
			tssum += tsi
			tsc.append( tssum )
		ns = len( self.ts )
		nt = len( self.t )
		v = []
		id = 0
		for ti in self.t:
			if ( ti > tsc[id] ):
				id += 1
			if ( id == ns ):
				break
			v.append( self.ds[id] / self.ts[id] )
		if ( len(v) == (nt-1) ):
				v.append( self.ds[ns-1] / self.ts[ns-1] )
		return v


	# Constructor
	def __init__( self, ts, ds, t ):
		self.ts = ts
		self.ds = ds
		self.t = t
		
